<template>
  <div class="login">
     
    <login v-show="loginShow" @regiest="toRegiest"/>
      <regiest v-show="regiestShow" @login='toRegiest'/>
  </div>
</template>

<script>
export default{
  //做数据缓存就要给该页面起名
    name:"allLogin"
}
</script>

<script setup>
import  login  from "./components/login.vue";
import  regiest  from "./components/regiest.vue";
import { useRoute, useRouter,onBeforeRouteUpdate } from "vue-router";
 import { ref } from "vue";
const loginShow=ref(true)
const regiestShow=ref(false)
const  toRegiest=()=>{
  loginShow.value=!loginShow.value
  regiestShow.value=!regiestShow.value
}
// const route = useRoute();
// const router = useRouter();
// const animation = ref('slide');
// onBeforeRouteUpdate((to,form,next)=>{
//   console.log(to.meta.index,form.meta.index);
//     if(to.meta.index > form.meta.index){
//         animation.value = 'slide-left'
//         next()

//     }else{
//         animation.value = 'slide-right'
//         next()
//     }
    
// })


</script>

<style lang="scss" scoped>
.login {
  display: flex;
  justify-content: center;
}
.demo-enter-from,
.demo-leave-to{
  opacity: 0;
}
.demo-enter-active,
.demo-leave-active{
  transition: all .4s;
}
.slide-right-enter-active,
.slide-right-leave-active,
.slide-left-enter-active,
.slide-left-leave-active {
  will-change: transform;
  transition: all 1000ms;
  position: absolute;
}
// 右滑初始装状态
.slide-right-enter {
   opacity: 0;
  transform: translateX(-100%);
}

// 右滑执行状态
.slide-right-leave-active {
   opacity: 0;
  transform: translateX(100%);
}
// 右滑最终状态
.slide-right-enter-to {
   opacity: 1;
  transform: translateX(0);
}
// 左滑初始装状态
.slide-left-enter {
   opacity: 0;
  transform: translateX(100%);
}
// 左滑执行状态
.slide-left-leave-active {
   opacity: 0;
  transform: translateX(-100%);
}
// 左滑最终状态
.slide-right-enter-to {
   opacity: 1;
  transform: translateX(0);
}
</style>
